package cn.txun.csmall.all.adapter.impl;

import cn.txun.csmall.all.service.ICartService;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class RpcCartService {

    @DubboReference
    private ICartService cartService;

    public void cartDeleteFallBack(String userId,String commodityCode,Throwable e){
        log.error("删除userId:{},商品:{},删除失败 ,异常:{}",userId,commodityCode,e);
    }

    //删除购物车，远程调用
    @SentinelResource(value = "cartDelete",fallback = "cartDeleteFallBack")
    public void rpcCartDelete(String userId,String commodityCode){
        cartService.deleteUserCart(userId, commodityCode);
    }
}
